package luj.tool.jnproxyan.proxy.admin.util;

import luj.tool.jnproxyan.framework.proxy.actor.tell.ActorTeller;
import luj.tool.jnproxyan.proxy.admin.AdminHttpHandler;
import luj.tool.jnproxyan.proxy.network.socks.actor.root.Socks5Actor;
import org.springframework.stereotype.Component;

import java.util.function.BiFunction;

@Component
public class SocksTeller {

  public SocksTeller inject(AdminHttpHandler.Context handleCtx) {
    var result = new SocksTeller();
    result._handleCtx = handleCtx;
    return result;
  }

  public <M> void tell(Class<M> type, BiFunction<ActorTeller.MBean, M, ActorTeller.MBean> msg) {
    _handleCtx.actor(Socks5Actor.class).tell(type, msg);
  }

  AdminHttpHandler.Context _handleCtx;
}
